home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
TEX-DIST
/
DISK1.GZ00
/
fnts
/
Fonts.decache
< prev
next >
Wrap
Text File
|
1994-01-25
|
3KB
|
120 lines
#!/usr/local/bin/perl
#
# Take pk fonts from the cache and install in the correct
# directory. Decides whether a bitmap font should be generated.
# Asks about each font before installing.
sub abs { ($_[0] > 0) ? $_[0] : -$_[0]; }
# Directories are numbered mf1...mf$mfdirs
$mfdirs = 5;
# "Best" resolution of a bitmap font
$dpi = 300;
chdir('$.usr.local.TeX.Fonts');
while (<cache.*>)
{
# Only handle directories in the cache directory.
if (-d $_)
{
s/cache\.//;
$font = $_;
print "$font: Install ? ";
chop($_ = <STDIN>);
if (/^[Yy]/)
{
# Find the font's home directory.
$j = 0;
for ($i=1; $i<=$mfdirs; $i++)
{
if (-d "mf$i.$font")
{
$j = $i;
}
}
if ($j == 0)
{
die "Can't find $font"."'s directory\n";
}
# Move all the pk fonts across.
print "Moving the pk fonts...";
while (<cache.$font.*pk>)
{
/\.([0-9]+pk)/;
rename("cache.$font.$1", "mf$j.$font.$1");
print "$1...";
}
print "\n";
# Now decide whether to make a font file.
print "Checking for RISC OS font...";
if ((-f "mf$j.$font.IntMetrics") && (-f "mf$j.$font.Outlines"))
{
print "Congratulations! It's an outline font!\n";
}
else
{
# Look through the PK fonts present and try
# to find the "best". My definition of "best"
# is "Closest to $dpi"
print "Hmmm, it's a bitmap. I'll try to optimise!\n";
chdir("mf$j.$font");
$best = 0;
while (<*pk>)
{
/([0-9]+)pk/;
if (&abs($1 - $dpi) < &abs($best - $dpi))
{
$best = $1;
}
}
if ($best == 0)
{
print "No improvement found\n";
}
else
{
print "OK. I'm going to make a $best dpi font\n";
# Open the "x90y45" file to get the bitmap name.
# Check that the real bitmap exists.
if ((open(FONT, "x90y45")) &&
($realfont = <FONT>) &&
(close(FONT)) &&
(-f $realfont))
{
# OK, they've all passed the tests
# Zap the old font files.
print "Deleting the old bitmaps\n";
unlink($realfont);
unlink("IntMetrics");
unlink("x90y45");
}
# Move back up a directory, temporarily
# unpack the "best" entry and create the
# RISC OS font.
chdir("^");
system("pktogf $font.$best"."pk $font.$best"."gf");
system("gftofnt -v1 $font.$best"."gf");
unlink("$font.$best"."gf");
chdir("^");
}
}
# Ok, installed the font. Now zap the cache entry
print "Removing cache entry\n";
while (<cache.$font.*>)
{
unlink("$_");
}
unlink("cache.$font");
}
}
}
chdir('\\');